package cn.yuemouren.stack;

import cn.yuemouren.linkedlist.LinkedList;

/**
 * @Author: Timi
 * @Description: 链表实现栈
 * @Date: 2020/5/14 11:33
 */
public class LinkedListStack<T> implements Stack<T>{

    private LinkedList<T> stack;

    public LinkedListStack() {
        stack = new LinkedList<T>();
    }

    @Override
    public void push(T t) {
        stack.addFirst(t);
    }

    @Override
    public T pop() {
        return stack.removeFirst();
    }

    @Override
    public T peek() {
        return stack.getFirst();
    }

    @Override
    public int getSize() {
        return stack.getSize();
    }

    @Override
    public boolean isEmpty() {
        return stack.isEmpty();
    }
}
